package com.spring.aop.config;

import com.spring.aop.model.MyBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StopWatch;

/**
 * 每一行代码，都是改变世界的力量
 *
 * @author 郭帅
 * @date 2022/11/15 14:09
 */
@Configuration
public class TestConditionalOnProperty {


    @Bean
    public MyBean myBean2() {
        System.out.println("---mybean2");
        return new MyBean();
    }

    @Bean
    @ConditionalOnMissingBean(MyBean.class)
    public MyBean myBean() {
        System.out.println("---mybean");
        return new MyBean();
    }

    public static void main(String[] args) {
        StopWatch stopWatch = new StopWatch("hhh");
        stopWatch.start("123");
        stopWatch.stop();
        System.out.println(stopWatch.prettyPrint());
    }
}

